'use strict';

const {Controller} = require('egg');

class classNoticeController extends Controller{
  async add(){
    const {ctx} = this;
    const req = ctx.request.body;
    const res = await ctx.service.classNoticeService.add(
        req.title,
        req.content,
        req.u_id,
        req.c_id
    )
    ctx.body = ctx.helper.json(
        res.data ? res.data : null,
        res.suc ? 200 : 500,
        res.msg
    );
  }

  async del(){
    const {ctx} = this;
    const req = ctx.request.body;
    const res = await ctx.service.classNoticeService.del(
        req.id
    )
    ctx.body = ctx.helper.json(
        res.data ? res.data : null,
        res.suc ? 200 : 500,
        res.msg
    );
  }

  async getOne(){
    const {ctx} = this;
    const req = ctx.request.body;
    const res = await ctx.service.classNoticeService.getOne(
        req
    )
    ctx.body = ctx.helper.json(
        res.data ? res.data : null,
        res.suc ? 200 : 500,
        res.msg
    );
  }
  async classGetAll(){
    const {ctx} = this;
    const req = ctx.request.body;
    const res = await ctx.service.classNoticeService.classGetAll(
        req.c_id
    )
    ctx.body = ctx.helper.json(
        res.data ? res.data : null,
        res.suc ? 200 : 500,
        res.msg
    );
  }
}
module.exports = classNoticeController